package com.vue.power.backend.sys.controller;

import com.vue.power.backend.sys.entity.User;
import com.vue.power.backend.sys.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class MainController {

    @Autowired
    private UserService userService;

    /**
     * 功能描述：根据token来判定当前的用户是否有权限
     * @param auth
     * @return
     */
    @PostMapping("auth")
    public Map<String,Object> auth(@RequestBody Map<String,Object> auth){
        return userService.authByToken(auth);
    }


    /**
     * 功能描述：根据用户登录成功以后的token来查找用户的数据
     * @param user
     * @return
     */
    @PostMapping("getUserInfo")
    public Map<String,Object> getUserInfo(@RequestBody User user){
        return userService.getUserByToken(user);
    }

    /**
     * 功能描述：根据用户的账号和密码实现用户的登录功能
     * @param user
     * @return
     */
    @PostMapping("login")
    public Map<String,Object> login(@RequestBody User user){
        return userService.userLogin(user);
    }

}
